'use strict';

module.exports = app => {
    class TeachingService extends app.Service {
        constructor(ctx) {
            super(ctx);
        }


        async getinformation(params = 1) {
            const result = await this.ctx.fetch(this.app.urls('teacherQuestionlist'), {
                method: 'get',
                dataType: 'json',
                data:{
                    pageNo:params,
                }
            });
            let data = result.data;

            this.app.logger.info(data);

            if (data.code != 200){
                throw new Error(data.message ? data.message : 'error');
            }

            return data.data;
        }

        async delinformation(params){
            const result = await this.ctx.fetch(this.app.urls('delinformation'), {
                method: 'post',
                dataType: 'json',
                data:{
                  id:params.id
                },
            });
            let data = result.data;

            this.app.logger.info(data);

            if (data.code != 200){
                throw new Error(data.message ? data.message : 'error');
            }

            return data.data;
        }

    }

    return TeachingService;
};
